<template>
  <div class="page">
    <div class="main">
      <div class="header-bg">
        <div class="navTitle">我的</div>
        <div class="info">
          <div class="_left">
            <img src="../assets/img/photo_default@2x.png" alt="" />
            <div v-if="!username">
              <div class="t">HI，朋友</div>
              <div>登录解锁更多功能</div>
              <div >HI，朋友</div>
            </div>
            <div v-if="username">
              <div class="t">HI，{{ username }}</div>
              <div>快来一起体验快乐之旅把</div>
            </div>
          </div>
          <div v-if="!username" class="login-bg" @click="goLogin">立即登录</div>
        </div>
      </div>
      <div class="rectangle">
        <div class="t-r">其他功能</div>
        <ul>
          <li @click="clickKF">
            <img src="../assets/img/mine_service_icon@2x.png" alt="" />
            <div>联系客服</div>
          </li>
          <li @click="clickLY">
            <img src="../assets/img/mine_notice_icon@2x.png" alt="" />
            <div>建议与反馈</div>
          </li>
          <li @click="goUserInfo">
            <img src="../assets/img/mine_icon@2x.png" alt="" />
            <div>个人中心</div>
          </li>
        </ul>
      </div>
    </div>
    <TabBar :currentIndex="currentIndex" />
  </div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import NavBar from "../components/NavBar.vue";
import TabBar from "../components/TabBar.vue";
import { showToast, showDialog } from "vant";
const router = useRouter();
const isBack = ref(false);
const username = ref("");
const currentIndex = ref(2);
const goLogin = () => {
  router.push("/login");
};
const clickKF = () => {
  showDialog({
    title: "客服电话",
    message: "0371-2220000",
    theme: "round-button",
    confirmButtonColor: "#1e80ff",
  }).then(() => {
    // on close
  });
};
const click = () => {
  //   router.push("/login");
  showToast("程序猿正在加班开发中，敬请期待");
};
const clickLY = () => {
  if (!username.value) {
    showToast("请先登录");
    return;
  }
  router.push("/feedback");
};
const goUserInfo = () => {
  if (!username.value) {
    showToast("请先登录");
    return;
  }
  router.push("/userInfo");
};
username.value = localStorage.getItem("h5_token");
onMounted(() => {
  console.log("mounted");
  console.log(router);
});
</script>
<style scoped lang="less">
.page {
  width: 100%;
  min-height: 100vh;
  background-color: #f8f8f8;
}

.header-bg {
  width: 100%;
  height: 160px;
  background: url("../assets/img/mine_img_top@2x.png") no-repeat left center;
  background-size: 100% 100%;
  position: relative;
}
.info {
  width: 92%;
  height: 105px;
  background-color: #ffffff;
  border-radius: 8px;
  position: absolute;
  left: 50%;
  bottom: -50px;
  transform: translate(-50%, 0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  .login-bg {
    width: 80px;
    height: 30px;
    background-color: #1e80ff;
    border-radius: 15px;
    line-height: 30px;
    text-align: center;
    color: #fff;
    font-size: 13px;
    margin-right: 15px;
  }
  ._left {
    margin-left: 15px;
    display: flex;
    align-items: center;
    .t {
      font-size: 18px;
      font-weight: bold;
      color: #333333;
      margin-bottom: 5px;
    }
    img {
      width: 48px;
      height: 48 px;
      margin-right: 15px;
    }
  }
}
.navTitle {
  height: var(--van-nav-bar-height);
  line-height: var(--van-nav-bar-height);
  text-align: center;
  color: var(--van-nav-bar-title-text-color);
  font-weight: var(--van-font-bold);
  font-size: var(--van-nav-bar-title-font-size);
}
.rectangle {
  width: 92%;
  height: 146px;
  background-color: #ffffff;
  border-radius: 8px;
  margin: 70px auto 30px;
  overflow: hidden;
  .t-r {
    font-size: 18px;
    font-weight: bold;
    color: #333333;
    margin: 20px 0 0 15px;
  }
  ul {
    display: flex;
    justify-content: space-around;
    margin: 15px 0;
    li {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      img {
        width: 28px;
        height: 28px;
        margin-bottom: 8px;
      }
    }
  }
}
</style>
